<%@ page language="java"  pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body class="no-skin">
	<!-- PAGE CONTENT BEGINS -->
			<table width="100%" border="0">
				<tr>
				    <td width="9%" align="right" nowrap="nowrap"><strong>机构代码：</strong><input type="hidden" id="parentCode" value="${parentCode}"></td>
				    <td width="22%"><input name="organCode" type="text" id="organCode" maxlength="50" />    </td>
				    <td width="9%" align="right" nowrap="nowrap"><strong>机构名称：</strong></td>
				    <td width="22%"><input name="organName" type="text" id="organName" maxlength="100" />    </td>
				    <td align="right" nowrap="nowrap"><strong>状态：</strong></td>
				    <td align="left" nowrap="nowrap">
				      <select name="select" id="organStatus">
							<option selected="selected" value="">全部</option>
							<option value=1>有效</option>
							<option value=0>无效</option>
					  </select>
					</td>
				    <td width="22%">
					    <button   class="btn btn-sm btn-info" type="button" onclick="initTable();">
					       <i class="ace-icon glyphicon glyphicon-search bigger-110"></i>查 询
						</button>
								
						<button class="btn btn-sm btn-warning" type="button" onclick="toAddOrg();" >
						 	<i class="ace-icon glyphicon glyphicon-plus bigger-110"></i>新 增
						</button>
					</td>
			  </tr>
		</table>
	</div>
	<!--查询区域end-->
	<div id="faq-tab-1" class="tab-pane fade in active">
		<!--查询结果-->
		<div style="overflow-x:auto;  margin-top:10px">
			<table id="org_sample_table" class="table table-striped table-bordered table-hover" style="margin:0; "  >
				<caption></caption>
				<thead>
					<tr>
						<th nowrap="nowrap" class="center"> 序号 </th>
						<th nowrap="nowrap"> 机构代码 </th>								    
				        <th nowrap="nowrap" >机构名称</th>
				        <th nowrap="nowrap">机构简称</th>
				        <!--<th nowrap="nowrap">描述</th>-->
				        <th nowrap="nowrap">状态</th>
				        <th nowrap="nowrap">操作</th>
				    </tr>
				</thead>
				<tbody>
		      	</tbody>
		   </table>
		</div>
	<script type="text/javascript">
	     jQuery(function($) {
			initTable();
		});
		function initTable(){
			$("#org_sample_table").dataTable().fnDestroy();
			json={};
			json.showLineNuber=true;
			json.id="org_sample_table";
		    json.url=contextPath+'/auth/org/getOrgListByParent.json';
		    json.param=[{"name" : "orgCode","value" : $("#organCode").val()},
		                {"name" : "parentCode","value" : $("#parentCode").val()},
		                {"name" : "orgName","value" : $("#organName").val()},
		                {"name" : "status","value" : $("#organStatus").val()}
		               ];
		    json.columns=[  {"sWidth": "40px","sClass":"text-center"},
							{"mData" : "orgCode","sWidth": "100px","sClass":"text-center"},
								{"mData" : "orgName","sWidth": "100px","sClass":"text-center"},
								{"mData" : "simpleName","sWidth": "100px","sClass":"text-center"},
								<%/*{"mData" : "remark","sWidth": "100px","sClass":"text-center"},*/%>
								{"mData" : "status","sWidth": "40px","sClass":"text-center",
									"mRender" : function(data, type, row) {
									if(data == 1){
										return '有效';
									}else{
										return '无效';
									}
								}
								},
								{"mData" : "orgId","sWidth": "40px","sClass":"text-center",
								"mRender" : function(data, type, row) {
									if(data){
										return '&nbsp;&nbsp;<a style="color:#428bca" href="../../auth/org/toEditOrg.htm?orgId='+data+'" >修改</a>&nbsp;&nbsp;';
										//return '&nbsp;&nbsp;<a style="color:#428bca" href="../../auth/org/toEditOrg.htm?orgId='+data+'" >修改</a>&nbsp;&nbsp;<a style="color:#428bca" href="javascript:toDeleteOrg('+data+')" >删除</a>&nbsp;&nbsp;';
									}
								}
								}
					];
		    var oTable1=TableManaged(json).init();
		}
		
		function toAddOrg(){
			var parentCode = $("#parentCode").val();
			window.location.href="../../auth/org/toAddOrg.htm?parentCode="+parentCode;
		}
		
		function toDeleteOrg(orgId){
			$.Confirm('请确认是否删除该组织机构？','',deleteOrg(orgId));
		}
		function deleteOrg(orgId){
				 $.ajax({
		           url : contextPath + "/auth/org/deleteOrg.json",
		           type : "post",
		           data : {orgId:orgId},
		           async : false,
		           success : function(data){
		             var msg = eval("("+data+")");
		             $.Alert(msg.message,'',toOrgList);
		           },
		           error : function(){
		             //$.Alert("服务异常，请稍后尝试！");
		           }
		         });
		}
		
		function toOrgList(){
		    var parentCode = $("#parentCode").val();
		    location.href = "../../auth/org/toOrgList.htm?parentCode="+parentCode;
		}
	</script>
</body>
</html>
